import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);

const module = {
    state: {
        // 底部
        arr: ['首页', '分类', '', '购物车', '个人中心'],
        // 商品
        some: [
            [{
                    src: require('../assets/user/g-san.png'),
                    title: '会呼吸丝滑蜜粉',
                    gg: '蜜粉',
                    money: 166.06,
                    num: 1,
                    tax: 0.165,
                },
                {
                    src: require('../assets/user/g-san.png'),
                    title: '会呼吸丝滑蜜粉',
                    gg: '蜜粉',
                    money: 166.06,
                    num: 1,
                    tax: 0.165
                }
            ],
            [{
                src: require('../assets/user/g-san.png'),
                title: '会呼吸丝滑蜜粉',
                gg: '蜜粉',
                money: 166.06,
                num: 1,
                tax: 0.165
            }, ],
        ],
        sort: ['日本直邮', '韩国直邮'],
        like: [
            [{
                    src: require('../assets/user/lipstick2.png'),
                    zi: '不易脱妆口红',
                    money: 59
                },
                {
                    src: require('../assets/user/lipstick1.png'),
                    zi: '花蕊唇彩',
                    money: 129
                },
                {
                    src: require('../assets/user/lipstick3.png'),
                    zi: '娇吻玉口红',
                    money: 88
                },
                {
                    src: require('../assets/user/lipstick4.png'),
                    zi: '丰润蜜唇彩',
                    money: 99
                },
            ],
            [{
                    src: require('../assets/user/lipstick2.png'),
                    zi: '不易脱妆口红',
                    money: 59
                },
                {
                    src: require('../assets/user/lipstick1.png'),
                    zi: '花蕊唇彩',
                    money: 129
                },
                {
                    src: require('../assets/user/lipstick3.png'),
                    zi: '娇吻玉口红',
                    money: 88
                },
                {
                    src: require('../assets/user/lipstick4.png'),
                    zi: '丰润蜜唇彩',
                    money: 99
                },
            ],
        ],
        // 支付
        zhifu: [{
                src: require('../assets/user/zhifubao.png'),
                name: '支付宝支付'
            },
            {
                src: require('../assets/user/weixin.png'),
                name: '微信支付'
            }
        ],
        // 首页图片
        tu: require('../assets/user/xuanliyanzhuang.png'),
        // 首页商品
        tuall: [{
                src: require('../assets/user/lipstick2.png'),
                zi: '不易脱妆口红',
                money: 59
            },
            {
                src: require('../assets/user/lipstick1.png'),
                zi: '花蕊唇彩',
                money: 129
            },
            {
                src: require('../assets/user/lipstick3.png'),
                zi: '娇吻玉口红',
                money: 88
            },
        ],
        // 美妆专区
        mei: [
            [{
                    src: require('../assets/user/g-san.png'),
                    zi: '会呼吸丝滑蜜粉',
                    time1: 0,
                    time2: 0,
                    time3: 0
                },
                {
                    src: require('../assets/user/tu1.png'),
                    zi: 'BB矿物粉饼9g',
                    time1: 0,
                    time2: 0,
                    time3: 0
                },
                {
                    src: require('../assets/user/tu2.png'),
                    zi: '植萃腮红胭脂',
                    time1: 0,
                    time2: 0,
                    time3: 0
                },
                {
                    src: require('../assets/user/tu3.png'),
                    zi: '蜗牛饰容BB霜50g',
                    time1: 0,
                    time2: 0,
                    time3: 0
                },
                {
                    src: require('../assets/user/ru4.png'),
                    zi: '植萃莹透粉饼',
                    time1: 0,
                    time2: 0,
                    time3: 0
                },
                {
                    src: require('../assets/user/tu5.png'),
                    zi: '矿物晶纯清透蜜粉',
                    time1: 0,
                    time2: 0,
                    time3: 0
                },
            ],
        ],
        fenlei: ['美妆专区', '美食专区', '母婴专区', '保健品', '心得优品'],
        // 用户个人信息
        name: '登录/注册',
        headImg: 'https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=1629251846,4126644826&fm=26&gp=0.jpg',
        //用户id
        mid: '',
        msid: '',
        arr1: ['待支付', '待发货', '待收货', '交易完成'],
        // 客服反馈
        feedBack1: [{
                tit: '联系客服',
                workTime: '9:00—24:00',
                list: [{
                    n: '订单咨询',
                    txt: '订单修改、取消订单、订单查询'
                }, {
                    n: '物流咨询',
                    txt: '物流信息查询、催物流'
                }, {
                    n: '售后咨询',
                    txt: '商品质疑、退换货、投诉与建议'
                }, {
                    n: '其他咨询',
                    txt: ''
                }]
            },
            {
                tit: '常见问题',
                list: ['食品安全科普', '为什么还没有发货？', '发货了为什么还没收到？', '其他问题'],
            }
        ],
        // 订单处理
        order: [{
            tit: ['全部订单', '待支付', '待发货', '待收货', '交易完成']
        }],
    },
    mutations: {
        changem(state) {
            for (var i = 0; i < state.some.length; i++) {
                state.some[i]++;
            }
        }
    },
    // 类似vue中的计算属性，他注意针对状态进行操作
    getters: {
        getArr(state) {
            return state.arr.filter(item => {
                return item % 2 == 0;
            })
        }
    },
    // Action 类似于 mutation，不同在于：
    // Action 提交的是 mutation，而不是直接变更状态。
    // Action 可以包含任意异步操作。
    actions: {
        abc(context) {
            console.log(context.state.count);
            context.commit('abc');
        }
    }
};

const store = new Vuex.Store(module);
export default store;